Skip to content

Conversation

healthykim
Copy link
Contributor

@healthykim healthykim commented Sep 29, 2025

This PR removes the alternates and announced maps in tx_fetcher.

  • The alternates map is used only to check whether a transaction is in stage 2 (queued), and the announced map is used only to check whether a transaction is in stage 3 (fetching).
  • However, regardless of the stage, transactions eventually go through a similar process (being marked in the announces map). So maintaining two separate maps seems unnecessary.
  • Instead, we can iterate over the announces map, which is shared across stage 2 and stage 3, to perform the same check.

Given that the peer set is usually small (e.g., 50 by default), this iteration is expected to be fast.

@cskiraly cskiraly self-assigned this Sep 29, 2025
@cskiraly cskiraly self-requested a review September 29, 2025 07:54
@rjl493456442 rjl493456442 self-assigned this Sep 29, 2025
@cskiraly
Copy link
Contributor

cskiraly commented Oct 9, 2025

@healthykim So we change how we would operate with many peers, right? I was running nodes like that, and would like to keep that possible. Maybe the change in load is marginal, just want to double-check.

txFetcherWaitingPeers = metrics.NewRegisteredGauge("eth/fetcher/transaction/waiting/peers", nil)
txFetcherWaitingHashes = metrics.NewRegisteredGauge("eth/fetcher/transaction/waiting/hashes", nil)
txFetcherQueueingPeers = metrics.NewRegisteredGauge("eth/fetcher/transaction/queueing/peers", nil)
txFetcherQueueingHashes = metrics.NewRegisteredGauge("eth/fetcher/transaction/queueing/hashes", nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to keep this metric somehow

Copy link
Contributor Author

@healthykim healthykim Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the current change resolves this comment but it was not. I made this unresolved again. I'll take a look

}
}

func (f *TxFetcher) announced(hash common.Hash) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We rely on the announces map[string]map[common.Hash]*txMetadataWithSeq for determining whether the tx is announced or not.

You are right that the map iteration should be fast enough, especially the size of peer set is very limited. But we should also consider that this function will be invoked for every tx announcement.

However, another downside is we lose the ability to know how many transactions are in the announced status.

An alternative approach will be maintaining the map like

announced map[common.Hash]struct{}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants